package com.dr.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.dr.common.Const;
import com.dr.pojo.Constant;
import com.dr.pojo.Dept;
import com.dr.pojo.Regist;
import com.dr.pojo.User;
import com.dr.service.ConstantService;
import com.dr.service.DeptService;
import com.dr.service.RegistService;
import com.dr.service.UserService;
//@RestController 
@Controller
@RequestMapping("/rg")
public class RegistController { 
//	@Autowired
//	private InvoiceService invoiceService;
//	
//	@Autowired
//	private RegistService registService; 
//	
//	@Autowired
//	private RegistLevelService levelService; 
//	
//	@Autowired
//	private SchedulingService schedulingService; 
//	
//	//加载挂号页面
	@RequestMapping("/regist")
	public String regist() {
//		//发票号
//		Invoice invoice = invoiceService.nextInvoice();
//		if(invoice!=null) {
//			md.addAttribute("invoice",invoice);
//		}
//	}
//	
//	
//	@RequestMapping("/toAdd")
//	public ModelAndView toAdd() {
//		//System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
//		ModelAndView mav = new ModelAndView();
//		List<Dept> deptList = deptService.findDeptList();
//		List<Constant> constantList = constantService.findConstantList();
//		List<Regist> registList = registService.findRegistList();
//		mav.addObject("deptList", deptList); 
//		mav.addObject("constantList", constantList); 
//		mav.addObject("registList", registList); 
//		mav.setViewName("userManage/userAdd.html");		
//		return mav;
//	}
//	
//	@ResponseBody //  ajax方式提交@RestController = @Controller + @ResponseBody
//	@RequestMapping("/doAdd")
//	public Map<String,Object> doAdd(User user) {	
//		//System.out.println(user);
//		String userName = user.getUserName();
//		User addUser = userService.findUserByName(userName);
//		Map<String,Object> map=new HashMap<>();
//		if(addUser!=null) {
//			//账户存在		
//			//mav.addObject("attrInfoUserAdd","账户已存在");//硬编码
//			map.put("attrInfoUserAdd",Const.INF_USER_NAME_EXIST);			
//			map.put("status",Const.STATUS_FAILED);
//		}
//		else {
//			//账户不存在
//			int result = userService.insertUser(user);
//			if(result>0) {
//				map.put("status",Const.STATUS_SCUESS);
//			}
//			else {
//				map.put("status",Const.STATUS_FAILED);
//			}
//		}	
		return "/regist/regist.html";
	}

}
